
#include "ClassRoom.h"
#include "ClassMate.h"

ClassMate::ClassMate(const BString& name) : BObject(name)
{
	_money = 0;
	_homework_done = true;
}
ClassMate::~ClassMate()
{

}

const BString& ClassMate::information() const
{
	if (_information.empty())
	{
		const BString& gender = this->property("gender");
		int age = this->property("age");
		float weight = this->property("weight");
		const BString& native = this->property("native");
		_information << "name:" << this->name() << '\n';
		_information << "gender:" << gender << "\n";
		_information << "age:" << age << '\n';
		_information << "weight:" << weight << '\n';
		_information << "native:" << native << '\n';
	}
	return _information;
}

void ClassMate::setClassRoom(ClassRoom* classRoom)
{
	_classRoom = classRoom;
	this->emit("class-room-changed", BValue(_classRoom, true));
}

bool ClassMate::input(const BString& text, const BValue& value)
{
	if (text == "money")
	{
		_money = value;
		this->emit("money-changed", _money);
		return true;
	}
	return BObject::input(text, value);
}
bool ClassMate::query(const BString& text, BValue& value) const
{
	if (text == "money")
	{
		value = _money;
		return true;
	}
	if (text == "home-work-done")
	{
		value = _homework_done;
		return true;
	}
	return BObject::query(text, value);
}
